package cn.wetcland.urban.framework.controller;

import cn.dev33.satoken.annotation.SaCheckLogin;
import cn.wetcland.urban.common.AjaxResponse;
import cn.wetcland.urban.framework.annotation.SaCheckDriverLogin;
import cn.wetcland.urban.framework.dto.CustomerAppealDTO;
import cn.wetcland.urban.framework.service.UtAppealService;
import cn.wetcland.urban.generator.domain.UtAppeal;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/appeal")
public class AppealController {

    @Resource
    public UtAppealService appealService;

    @SaCheckLogin
    @PostMapping("/customerAppeal")
    public AjaxResponse customerAppeal(@Validated @RequestBody CustomerAppealDTO appealDTO) {
        appealService.handleCustomerAppeal(appealDTO);
        return AjaxResponse.success();
    }

    @SaCheckLogin
    @GetMapping("/customerAppealList/{status}")
    public AjaxResponse customerAppealList(@PathVariable Integer status) {
        List<UtAppeal> appealList = appealService.customerAppealList(status);
        return AjaxResponse.success(appealList);
    }

    @SaCheckDriverLogin
    @PostMapping("/driverAppeal")
    public AjaxResponse driverAppeal(@Validated @RequestBody CustomerAppealDTO appealDTO) {
        appealService.handleDriverAppeal(appealDTO);
        return AjaxResponse.success();
    }

    @SaCheckDriverLogin
    @GetMapping("/driverAppealList/{status}")
    public AjaxResponse driverAppealList(@PathVariable Integer status) {
        List<UtAppeal> appealList = appealService.driverAppealList(status);
        return AjaxResponse.success(appealList);
    }

}
